sum = 0
for x in range(1,1000):
    r1 = x % 3
    r2 = x % 5
    if r1 == 0 or r2 == 0:
        print x
        sum += x
print sum
